using System;
using System.Web;

namespace NopSolutions.NopCommerce.LuceneHelper
{
    public class HttpModule : IHttpModule
    {
        public void Dispose()
        {
            
        }

        public void Init(HttpApplication context)
        {
            context.BeginRequest += BeginRequest;
        }
        public void BeginRequest(object sender, EventArgs e)
        {
            //Products and variants
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductUpdated +=
                LuceneContext.Instance.ProductUpdated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductCreated +=
                LuceneContext.Instance.ProductCreated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductVariantUpdated +=
                LuceneContext.Instance.ProductVariantUpdated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductVariantCreated +=
                LuceneContext.Instance.ProductVariantCreated;

            //Product manu mappings
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductManufacturerCreated +=
                LuceneContext.Instance.ProductManufacturerCreated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductManufacturerUpdated +=
                LuceneContext.Instance.ProductManufacturerUpdated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductManufacturerDeleted +=
                LuceneContext.Instance.ProductManufacturerDeleted;

            //Product category mappings
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductCategoryCreated +=
                LuceneContext.Instance.ProductCategoryCreated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductCategoryUpdated +=
                LuceneContext.Instance.ProductCategoryUpdated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductCategoryDeleted +=
                LuceneContext.Instance.ProductCategoryDeleted;

            //Product spec mappings
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductSpecificationAttributeCreated +=
                LuceneContext.Instance.ProductSpecificationAttributeCreated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductSpecificationAttributeUpdated +=
                LuceneContext.Instance.ProductSpecificationAttributeUpdated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.ProductSpecificationAttributeDeleted +=
                LuceneContext.Instance.ProductSpecificationAttributeDeleted;

            //spec attributes
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.SpecificationAttributeCreated +=
                LuceneContext.Instance.SpecificationAttributeCreated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.SpecificationAttributeUpdated +=
                LuceneContext.Instance.SpecificationAttributeUpdated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.SpecificationAttributeDeleted +=
                LuceneContext.Instance.SpecificationAttributeDeleted;

            //spec options
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.SpecificationAttributeOptionCreated +=
                LuceneContext.Instance.SpecificationAttributeOptionCreated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.SpecificationAttributeOptionUpdated +=
                LuceneContext.Instance.SpecificationAttributeOptionUpdated;
            NopSolutions.NopCommerce.BusinessLogic.EventContext.Current.SpecificationAttributeOptionDeleted +=
                LuceneContext.Instance.SpecificationAttributeOptionDeleted;


        }
    }
}
